package com.uzai.console.service.stationcourse.impl;

import com.uzai.common.exception.BusinessException;
import com.uzai.common.result.ResponseCode;
import com.uzai.console.dto.stationcourse.ShortLinkJumpIdDto;
import com.uzai.console.entity.StationCourse;
import com.uzai.console.mapper.StationCourseMapper;
import com.uzai.console.service.stationcourse.StationCourseService;
import com.uzai.console.vo.stationcource.StationCourseVo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 站内教程
 * @author liuqi
 * @date 2021年08月13日 11:34
 */
@Service
public class StationCourseServiceImpl implements StationCourseService {

    Logger logger = LoggerFactory.getLogger(StationCourseServiceImpl.class);

    @Autowired
    private StationCourseMapper stationCourseMapper;

    /**
     * 根据跳转id查询站内教程
     * @author liuqi
     * @date 2021/8/13 11:38
     * @return null
     */
    public StationCourseVo findStationCourseByJumpId(ShortLinkJumpIdDto shortLinkJumpIdDto){
        StationCourseVo shortLinkVo = new StationCourseVo();
        if(StringUtils.isBlank(shortLinkJumpIdDto.getJumpId())){
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, "请输入跳转id");
        }

        //查询运营商短链接设置信息
        StationCourse stationCourse = stationCourseMapper.selectByJumpId(shortLinkJumpIdDto.getJumpId());
        if(stationCourse != null ){
            BeanUtils.copyProperties(stationCourse, shortLinkVo);
        }
        return shortLinkVo;
    }
}
